from django.contrib import admin

from language.models import Namespace, Transition


# Register your models here.
class BasicAdminModel(admin.ModelAdmin):
    search_fields = ["id", "__str__"]
    list_display = ["id", "__str__", "enabled", "priority"]
    list_editable = ["enabled", "priority"]
    exclude = ["deleted"]


    def get_queryset(self, request):
        result = super().get_queryset(request)
        return result.filter(deleted=False)


@admin.register(Namespace)
class NamespaceAdmin(BasicAdminModel):
    list_display = ["__str__", "description"]
    list_editable = list_display[2:]


@admin.register(Transition)
class TransitionAdmin(BasicAdminModel):
    list_display = ["__str__", "code", "path", "language"]
    list_editable = []
    list_filter = ["code", "path"]
